<template>
  <div class="btn">
    <!-- <button @click="addFn">点击+1</button> -->
    <!-- <button @click="reduceFn">点击、减1</button> -->
    <!-- 或 -->
    <!-- <button @click="$store.commit('increase',2)">点击、加1</button>
    <button @click="$store.dispatch('decreaseAsync')">点击、减1</button> -->

    <!-- 或 ...mapMutations ...mapActions-->
    <button @click="increase(2)">点击、加1</button>
    <button @click="decreaseAsync()">点击、延迟减1</button>

  </div>
</template>
<script>
import { mapMutations, mapActions } from 'vuex'
export default {
  name:'Home',
  methods: {
    /*
    addFn(){
      // 调用store中mutations里的increase方法
      // 传参的话，使用playload
      this.$store.commit('increase', 2)
    },
    reduceFn(){
      this.$store.dispatch('decreaseAsync');
    },
    */

   ...mapMutations(['increase']),
   ...mapActions(['decreaseAsync'])
  },
}
</script>